package cn.edu.xhu.library_management.user.controller.Applets;

import cn.edu.xhu.library_management.common.entity.R;
import cn.edu.xhu.library_management.user.client.BookClient;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: MMJ
 * @Date: 2023 - 04 - 23
 * @Description: 图书相关控制器
 */
@Api(tags = "小程序模块")
@ApiSort(5)
@RestController
@RequestMapping("/lm_user/user/applet")
public class BookController {

    @Resource
    private BookClient bookClient;

//    @Resource
//    private BookCategoryClient categoryClient;

    @GetMapping("/bookDetail/{bookId}")
    @ApiOperation(value = "图书Id，获取图书详情", produces = "application/json")
    @ApiOperationSupport(order = 511)
    public R getBookDetail(@PathVariable("bookId") Long bookId) {
        return bookClient.findBookDetail(bookId);
    }

    @GetMapping("/category/{pid}")
    @ApiOperation(value = "分类Id，获取子类", produces = "application/json")
    @ApiOperationSupport(order = 512)
    public R getCategory(@PathVariable(name = "pid") Long pid) {
        return bookClient.findCategoryByPid(pid);
    }

    @GetMapping("/book/category/{pid}")
    @ApiOperation(value = "通过分类查询图书", produces = "application/json")
    @ApiOperationSupport(order = 512)
    public R getBookByCategory(@PathVariable(name = "pid") Integer pid){
        return bookClient.findBookByCategory(pid);
    }


}
